
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Task;
import cn.edu.scau.cmi.hombio.domain.TaskIntervalCycle;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class TaskIntervalCycleServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected TaskIntervalCycleService service;

	/**
	 * Instantiates a new TaskIntervalCycleServiceTest.
	 *
	 */
	public TaskIntervalCycleServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteTaskIntervalCycleTask() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskIntervalCycleTask 
		Integer taskintervalcycle_id = 0;
		Integer related_task_id = 0;
		TaskIntervalCycle response = null;
		response = service.deleteTaskIntervalCycleTask(taskintervalcycle_id, related_task_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskIntervalCycleTask
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveTaskIntervalCycleTask() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskIntervalCycleTask 
		Integer id = 0;
		Task related_task = new cn.edu.scau.cmi.hombio.domain.Task();
		TaskIntervalCycle response = null;
		response = service.saveTaskIntervalCycleTask(id, related_task);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskIntervalCycleTask
	}

	/**
	 * Operation Unit Test
	* Return a count of all TaskIntervalCycle entity
	* 
	 */
	@Test
	public void countTaskIntervalCycles() {
		Integer response = null;
		response = service.countTaskIntervalCycles();
		// TODO: JUnit - Add assertions to test outputs of operation: countTaskIntervalCycles
	}

	/**
	 * Operation Unit Test
	* Save an existing TaskIntervalCycle entity
	* 
	 */
	@Test
	public void saveTaskIntervalCycle() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskIntervalCycle 
		TaskIntervalCycle taskintervalcycle = new cn.edu.scau.cmi.hombio.domain.TaskIntervalCycle();
		service.saveTaskIntervalCycle(taskintervalcycle);
	}

	/**
	 * Operation Unit Test
	* Load an existing TaskIntervalCycle entity
	* 
	 */
	@Test
	public void loadTaskIntervalCycles() {
		Set<TaskIntervalCycle> response = null;
		response = service.loadTaskIntervalCycles();
		// TODO: JUnit - Add assertions to test outputs of operation: loadTaskIntervalCycles
	}

	/**
	 * Operation Unit Test
	* Delete an existing TaskIntervalCycle entity
	* 
	 */
	@Test
	public void deleteTaskIntervalCycle() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskIntervalCycle 
		TaskIntervalCycle taskintervalcycle_1 = new cn.edu.scau.cmi.hombio.domain.TaskIntervalCycle();
		service.deleteTaskIntervalCycle(taskintervalcycle_1);
	}

	/**
	 * Operation Unit Test
	* Return all TaskIntervalCycle entity
	* 
	 */
	@Test
	public void findAllTaskIntervalCycles() {
		// TODO: JUnit - Populate test inputs for operation: findAllTaskIntervalCycles 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<TaskIntervalCycle> response = null;
		response = service.findAllTaskIntervalCycles(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllTaskIntervalCycles
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findTaskIntervalCycleByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findTaskIntervalCycleByPrimaryKey 
		Integer id_1 = 0;
		TaskIntervalCycle response = null;
		response = service.findTaskIntervalCycleByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findTaskIntervalCycleByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
